#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

//将 ABCDE12345 字符串写⼊到指定⽂件中, 并验证是否写⼊正确
int main(int argc, char const *argv[])
{
    char buffer[60] = "ABCDE12345";
    int fd;
    int wbytes;

    // 没有写入另一个文件参数
    if (argc != 2) {
        printf(stderr, "Usage: %s filename\n", argv[0]);
        return -1;
    }

    fd = open(argv[1], O_RDWR | O_CREAT | O_APPEND);

    // 读取不到文件 
    if (fd == -1 ){
        perror("open(): ");
        return -1;
    }
    // 10为写入字节数
    wbytes = write(fd, buffer, 10);
    if (wbytes == -1 ) {
        perror("write()");
        return -1;
    }
    close(fd);


    return 0;
}


